import java.util.ArrayList;
import java.util.List;

/**
 * @author LKQ
 * @date 2021/12/5 8:48
 * @description DFS，中序遍历，左中右
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        TreeNode leaf3 = new TreeNode(3, null, null);
        TreeNode leaf2 = new TreeNode(2, leaf3, null);
        TreeNode root = new TreeNode(1, null, leaf2);
        solution.inorderTraversal(root);
    }

    public List<Integer> inorderTraversal(TreeNode root) {
        List<Integer> res = new ArrayList<Integer>();
        inorder(root, res);
        return res;
    }
    public void inorder(TreeNode root, List<Integer> res) {
        if (root == null) {
            return;
        }
        inorder(root.left, res);
        res.add(root.val);
        inorder(root.right, res);
    }

}

